package service;

import util.CheckParameters;
import dao.OperationDAO;
import domain.Operation;
import exception.InvalidBusinessStateException;

public class OperationService extends GenericService<Operation> {

	private static OperationService instance;
	
	public static OperationService getInstance() {
		if (instance == null)
			instance = new OperationService();
		return instance;
	}
	
	public OperationService() {
		dao = OperationDAO.getInstance();
	}

	@Override
	protected void businessRules(Operation operation)
			throws InvalidBusinessStateException {
		CheckParameters.checkNull(operation.getRoommateGiver(), "Roommate who gives");
		CheckParameters.checkNull(operation.getRoommateReceiver(), "Roommate who receives");
		CheckParameters.checkNull(operation.getBalanceMonth(), "Current reference balance");
		CheckParameters.checkNotZero(operation.getAmount(), "Amount of operation");
	}

	@Override
	protected void handleDependencies(Operation entity)
			throws InvalidBusinessStateException {}

	@Override
	protected void cascadeDeletion(Integer id) throws InvalidBusinessStateException {}

}
